/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file has been modified by Huawei to verify type inference by adding verification statements.
*/

// === tests/cases/compiler/contextualSignatureInstantiationWithTypeParameterConstrainedToOuterTypeParameter.ts ===
declare function AssertType(value:any, type:string):void;
function f<T>() {
    function g<U extends T>(u: U): U { 
AssertType(g, "<U extends T>(U) => U");
return null 

AssertType(u, "U");

AssertType(null, "null");
}

AssertType(g, "<U extends T>(U) => U");
    return g;
}
let h: <V, W>(v: V, func: (v: V) => W) => W;
AssertType(h, "<V, W>(V, (V) => W) => W");
AssertType(v, "V");
AssertType(func, "(V) => W");
AssertType(v, "V");

let x = h("", f<string>()); // Call should succeed and x should be string. All type parameters should be instantiated to string
AssertType(x, "string");
AssertType(h("", f<string>()), "string");
AssertType(h, "<V, W>(V, (V) => W) => W");
AssertType("", "string");
AssertType(f<string>(), "<U extends string>(U) => U");
AssertType(f, "<T>() => <U extends T>(U) => U");


